package com.jsu.exhibitor.controller.v1;

import com.baomidou.mybatisplus.extension.api.R;
import com.jsu.exhibitor.service.ExhibitorService;
import com.jsu.exhibitor.service.impl.ExhibitorServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.model.common.dtos.ResponseResult;
import org.example.model.exhibitor.pojos.Exhibitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Slf4j
@RequestMapping("/exhibitor/web/v1")
@Api(tags = "展商信息控制器")
public class ExhibitorController {
    @Autowired
    private ExhibitorServiceImpl exhibitorService;
    @GetMapping("/")
    @ApiOperation(value = "获取展商信息")
    public ResponseResult getExhibitor(){
        log.info("获取展商信息");
        return exhibitorService.getExhibitor();
    }

    @GetMapping("/all")
    @ApiOperation(value = "获取所有展商信息")
    public ResponseResult getAllExhibitor(){
        log.info("获取所有展商信息");
        return exhibitorService.getAllExhibitor();
    }

    @ApiOperation(value = "获取固定展商信息")
    @GetMapping("/get/{id}")
    public ResponseResult getOneExhibitor(@PathVariable int id){
        return exhibitorService.getOneExhibitor(id);
    }

    @ApiOperation(value = "添加展商信息")
    @PostMapping("/add")
    public ResponseResult addExhibitor(@RequestBody Exhibitor exhibitor){
        return exhibitorService.addExhibitor(exhibitor);
    }

    @ApiOperation(value = "删除展商信息")
    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteExhibitor(@PathVariable Integer id){
        return exhibitorService.deleteExhibitor(id);
    }

    @ApiOperation(value = "更新展商信息")
    @PostMapping("/update")
    public ResponseResult updateExhibitor(@RequestBody Exhibitor exhibitor){
        return exhibitorService.updateExhibitor(exhibitor);
    }

    @ApiOperation(value = "模糊查询展商")
    @GetMapping("/search/{keyword}")
    public ResponseResult searchExhibitor(@PathVariable String keyword){
        return exhibitorService.searchExhibitor(keyword);
    }

    @ApiOperation(value = "批量删除展商")
    @DeleteMapping("/batchDelete")
    public ResponseResult batchDeleteExhibitor(@RequestBody Integer[] ids){
        return exhibitorService.batchDeleteExhibitor(ids);
    }

    @ApiOperation(value = "上传Excel文件")
    @PostMapping("/upload")
    public ResponseResult uploadExcel(@RequestParam("file") MultipartFile file) {
        return exhibitorService.uploadExcel(file);
    }

    @ApiOperation(value = "导出Excel文件")
    @GetMapping("/export")
    public ResponseResult exportExcel(@RequestParam("fileName") String fileName) {
        return exhibitorService.exportExcel(fileName);
    }
}
